<template>
  <el-menu
    :collapse="isCollapse"
    :default-active="activeMenu"
    background-color="#304156"
    text-color="#bfcbd9"
    active-text-color="#409eff"
    router
  >
    <side-menu-item v-for="route in asyncRoutes" :key="route.path" :menu="route"></side-menu-item>
  </el-menu>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
import { asyncRoutes } from '@/router'
import SideMenuItem from './SideMenuItem.vue'

export default defineComponent({
  name: 'SideMenu',
  components: { SideMenuItem },
  setup() {
    const store = useStore()
    const isCollapse = computed(() => store.getters.collapsed)

    const { path } = useRoute()
    const activeMenu = computed(() => path)

    return {
      isCollapse,
      asyncRoutes,
      activeMenu
    }
  }
})
</script>

<style lang="scss" scoped>
.el-menu {
  border-right: 0;
}
</style>

<style lang="scss">
.sider-menus {
  .horizontal-collapse-transition {
    -webkit-transition: 0s width ease-in-out, 0s padding-left ease-in-out,
      0s padding-right ease-in-out;
    transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
  }
}
</style>
